package com.feilong.edgeAI.adapter;

import android.os.Build;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.databinding.ViewDataBinding;
import androidx.recyclerview.widget.RecyclerView;

import com.aiibt.common.core.WDRecyclerAdapter;
import com.blankj.utilcode.util.ScreenUtils;
import com.feilong.edgeAI.R;
import com.feilong.edgeAI.databinding.HelpItemBinding;
import com.feilong.edgeAI.databinding.HomeCommandItemBinding;
import com.feilong.edgeAI.model.Commands;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
//zh_TW/en_US/zh_CN
public class HelpAdapter extends WDRecyclerAdapter<Integer> {
    private int width;
    private int[] imgsCN = {R.mipmap.feilongdashi_china_0_01,R.mipmap.feilongdashi_china_0_02,R.mipmap.feilongdashi_china_0_03,R.mipmap.feilongdashi_china_0_04,R.mipmap.feilongdashi_china_0_05,R.mipmap.feilongdashi_china_0_06,R.mipmap.feilongdashi_china_0_07,R.mipmap.feilongdashi_china_0_08,R.mipmap.feilongdashi_china_0_09,R.mipmap.feilongdashi_china_0_10,R.mipmap.feilongdashi_china_0_11,R.mipmap.feilongdashi_china_0_12,R.mipmap.feilongdashi_china_0_13,R.mipmap.feilongdashi_china_0_14};
    private int[] imgsTW = {R.mipmap.feilongdashi_fanti_01,R.mipmap.feilongdashi_fanti_02,R.mipmap.feilongdashi_fanti_03,R.mipmap.feilongdashi_fanti_04,R.mipmap.feilongdashi_fanti_05,R.mipmap.feilongdashi_fanti_06,R.mipmap.feilongdashi_fanti_07,R.mipmap.feilongdashi_fanti_08,R.mipmap.feilongdashi_fanti_09,R.mipmap.feilongdashi_fanti_10,R.mipmap.feilongdashi_fanti_11,R.mipmap.feilongdashi_fanti_12,R.mipmap.feilongdashi_fanti_13,R.mipmap.feilongdashi_fanti_14};
    private int[] imgsEN = {R.mipmap.feilongdashi_english_01,R.mipmap.feilongdashi_english_02,R.mipmap.feilongdashi_english_03,R.mipmap.feilongdashi_english_04
            ,R.mipmap.feilongdashi_english_05,R.mipmap.feilongdashi_english_06,R.mipmap.feilongdashi_english_07,R.mipmap.feilongdashi_english_08
            ,R.mipmap.feilongdashi_english_09,R.mipmap.feilongdashi_english_10,R.mipmap.feilongdashi_english_11,R.mipmap.feilongdashi_english_12,R.mipmap.feilongdashi_english_13,R.mipmap.feilongdashi_english_14};
    @RequiresApi(api = Build.VERSION_CODES.N)
    public HelpAdapter() {
        List<Integer> datas = new ArrayList<>();
        if("zh".equals(Locale.getDefault().getLanguage())){
            if("CN".equals(Locale.getDefault().getCountry())){
                datas.addAll(Arrays.stream(imgsCN).boxed().collect(Collectors.toList()));
            }else{
                datas.addAll(Arrays.stream(imgsTW).boxed().collect(Collectors.toList()));
            }
        }else {
            datas.addAll(Arrays.stream(imgsEN).boxed().collect(Collectors.toList()));
        }
        addAll(datas);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.help_item;
    }

    @Override
    protected void bindView(ViewDataBinding binding, Integer item, int position) {
        HelpItemBinding b = (HelpItemBinding) binding;
        b.imageview.setImageResource(item);
    }

    static class ImageHolder extends RecyclerView.ViewHolder {

        public ImageHolder(@NonNull View view) {
            super(view);
        }
    }
    public interface OnItemClickListener<T>{
        void onItemClick(T item);
    }
    private OnItemClickListener onItemClickListener;
    public void setOnItemClickListener(OnItemClickListener onItemClickListener){
        this.onItemClickListener = onItemClickListener;
    }
}
